import Vue from 'vue'
import Router from 'vue-router'
const _import = require('./_import_' + process.env.NODE_ENV)
// in development env not use Lazy Loading,because Lazy Loading too many pages will cause webpack hot update too slow.so only in production use Lazy Loading

/* layout */
import Layout from '../views/layout/Layout'

Vue.use(Router)

/**
* icon : the icon show in the sidebar
* hidden : if `hidden:true` will not show in the sidebar
* redirect : if `redirect:noredirect` will not redirct in the levelbar
* noDropdown : if `noDropdown:true` will not has submenu in the sidebar
* meta : `{ role: ['admin'] }`  will control the page role
**/
export const constantRouterMap = [
  {
    path: '/buttons',
    component: _import('buttons/index'),
    hidden: true
  },
  {
    path: '/login',
    component: _import('login/index'),
    redirect: '/login/1',
    hidden: true
  },
  {
    path: '/404',
    component: _import('404'),
    hidden: true
  },
  { path: '/login/:id', component: _import('login/index'), hidden: true },
  // { path: '/xtfq', component: _import('login/xiaoTongFenQi'), hidden: true },
  // { path: '/xjd', component: _import('login/xianJinDai'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{ path: 'dashboard', component: _import('dashboard/index') }]
  },
  {
    path: '/setting',
    component: Layout,
    redirect: 'noredirect',
    name: '系统设置',
    icon: 'yonghuming',
    children: [
      { path: 'password', name: '修改密码', icon: 'zonghe', component: _import('setting/password') },
      { path: 'username', name: '修改用户名', icon: 'zonghe', component: _import('setting/username') },
      { path: 'image', name: '修改头像', icon: 'zonghe', component: _import('setting/image') }
    ]
  },
  {
    path: '/userManage',
    component: Layout,
    redirect: 'noredirect',
    name: '用户管理',
    icon: 'yonghuming',
    children: [
      { path: 'list', name: '用户列表', icon: 'zonghe', component: _import('usermanage/list') }
    ]
  },
  {
    path: '/jingxiao',
    component: Layout,
    redirect: 'noredirect',
    name: '万经销',
    icon: 'yonghuming',
    children: [
      { path: 'jingxiaoshang', name: '经销商', icon: 'zonghe', component: _import('wan/jingxiao/list1') },
      { path: 'qudao', name: '渠道', icon: 'zonghe', component: _import('wan/jingxiao/list2') }
    ]
  },
  {
    path: '/gongying',
    component: Layout,
    redirect: 'noredirect',
    name: '万供应',
    icon: 'yonghuming',
    children: [
      { path: 'gongyingshang', name: '供应商', icon: 'zonghe', component: _import('wan/gongying/index') }
    ]
  },
  {
    path: '/one',
    component: Layout,
    redirect: 'noredirect',
    name: '一级目录',
    icon: 'yonghuming',
    children: [
      { path: 'list', name: '用户列表', icon: 'zonghe', component: _import('one/index') }
    ]
  },
  {
    path: '/table',
    component: Layout,
    redirect: '/table/index',
    icon: 'tubiao',
    noDropdown: true,
    children: [{ path: 'index', name: 'Table', component: _import('table/index'), meta: { role: ['admin'] }}]
  },

  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
